package cn.virens.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.virens.web.common.BaseController;

@Controller
public class IndexContorller extends BaseController {

	@RequestMapping(value = { "/", "index.jspx" })
	public String index() {
		return redirectUrl("/portal/index.jspx");
	}

	@RequestMapping(value = { "/manage", "manage.jspx" })
	public String manage() {
		return redirectUrl("/manage/index.jspx");
	}

	@RequestMapping("/test.jspx")
	public String test(Model model) {
		return test(null, model);
	}

	@RequestMapping("/test/{id}.jspx")
	public String test(@PathVariable(name = "id", required = false) String id, Model model) {
		return test(id, null, model);
	}

	@RequestMapping("/test/{id}/{type}.jspx")
	public String test(@PathVariable(name = "id", required = false) String id, @PathVariable(name = "type", required = false) String type, Model model) {
		model.addAttribute("id", id);
		model.addAttribute("type", type);

		return returnUrl("test");
	}

	@RequestMapping(value = "/error/{code}")
	public String error(@PathVariable String code) {
		return returnUrl("error/" + code);
	}
}
